package com.joplus.housekeeper.xmpp;

import org.jivesoftware.smack.packet.ExtensionElement;

/**
 * Created by zisheng on 2017/9/27.
 */

class SmackElement implements ExtensionElement {
    private String elementName = "extension";
    private String elementXmlns = "xmlns";
    private String elementId = "id";
    private String elementTime = "time";
    private String xmlns = "urn:xmpp:joplus:extension";
    private String id = "";
    private String time = "";
    private String type = "";

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getXmlns() {
        return xmlns;
    }

    public void setXmlns(String xmlns) {
        this.xmlns = xmlns;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    @Override
    public String getNamespace() {
        return "";
    }

    @Override
    public String getElementName() {
        return elementName;
    }

    @Override
    public CharSequence toXML() {
        StringBuilder sb = new StringBuilder();

        sb.append("<");
        sb.append(elementName);

        sb.append(" " + elementXmlns + "=\"" + xmlns + "\"");
   //     sb.append(" " + elementTime + "=\"" + time + "\"");
        sb.append(" " + elementId + "=\"" + id + "\"");
     /*   sb.append("<");
        sb.append(elementId);
        sb.append(">");
        sb.append(id);
        sb.append("</");
        sb.append(elementId);
        sb.append(">");

        sb.append("<");
        sb.append(elementXmlns);
        sb.append(">");
        sb.append(xmlns);
        sb.append("</");
        sb.append(elementXmlns);
        sb.append(">");

        sb.append("<");
        sb.append(elementTime);
        sb.append(">");
        sb.append(time);
        sb.append("</");
        sb.append(elementTime);
        sb.append(">");*/
        sb.append(">");

        sb.append("</");
        sb.append(elementName);
        sb.append(">");
        return sb.toString();
    }
}
